<?php

use think\facade\Route;

//miss路由，定义404
Route::miss(function () {
    @header("http/1.1 404 not found");
    @header("status: 404 not found");
    exit();
});

$domain = ['Access-Control-Allow-Headers' => 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-CSRF-TOKEN, X-Requested-With, token, sign'];


Route::get('/', 'index/index')->ext('html');

//Route::get('/index/communal', 'index/index/communal');

//首页
Route::group('index', function () {
    Route::get('/index', 'index/index');
    Route::get('/payment_open', 'index/payment_open');
    Route::post('/get_openid', 'index/get_openid');
    Route::get('/getCurriculum', 'index/getCurriculum');
    Route::get('/getCurriculumCate', 'index/getCurriculumCate');
    Route::get('/news_reveal', 'index/news_reveal');
    Route::get('/service_project', 'index/service_project');
    Route::get('/system_prompt', 'index/system_prompt');
    Route::get('/privacy_agreement', 'index/privacy_agreement');
    Route::get('/documentation', 'index/documentation');
    Route::get('/recommend', 'index/recommend');
    Route::get('/carousel', 'index/carousel');
    Route::get('/hot_cities', 'index/hot_cities');
    Route::get('/cooperative', 'index/cooperative');
    Route::get('/communal', 'index/communal');
})->allowCrossDomain($domain);

//新闻
Route::group('news', function () {
    Route::get('/index', 'news/index');
    Route::get('/info', 'news/info');
    Route::get('/getList', 'news/getList');
})->allowCrossDomain($domain);


//活动相关
Route::group('activity', function () {
    Route::get('/getList', 'activity/getList');
    Route::post('/release', 'activity/release');
    Route::post('/applyFor', 'activity/applyFor');
})->allowCrossDomain($domain)->middleware('verify');

//活动订单相关
Route::group('activityOrder', function () {
    Route::get('/getTemporary', 'activityOrder/getTemporary');
    Route::post('/submit', 'activityOrder/submit');
    Route::post('/confirmPayment', 'activityOrder/confirmPayment');
    Route::get('/getList', 'activityOrder/getList');
})->allowCrossDomain($domain)->middleware('verify');


//课程相关
Route::group('curriculum', function () {
    Route::get('/curriculumList', 'curriculum/curriculumList');
    Route::get('/details', 'curriculum/details');
    Route::get('/catalogue', 'curriculum/catalogue');
    Route::get('/section', 'curriculum/section');
    Route::post('/submit', 'curriculum/submit');
})->allowCrossDomain($domain)->middleware('verify');

//课程订单相关
Route::group('curriculumOrder', function () {
    Route::get('/getTemporary', 'curriculumOrder/getTemporary');
    Route::post('/submit', 'curriculumOrder/submit');
    Route::post('/confirmPayment', 'curriculumOrder/confirmPayment');
    Route::get('/getList', 'curriculumOrder/getList');
    Route::get('/my_order_details', 'curriculumOrder/my_order_details');
})->allowCrossDomain($domain)->middleware('verify');

//预约留言
Route::group('reservation', function () {
    Route::get('/maintain', 'reservation/maintain');
    Route::post('/save', 'reservation/save');
})->allowCrossDomain($domain)->middleware('verify');

//优惠券
Route::group('coupon', function () {
    Route::get('/info', 'coupon/info');
    Route::post('/receive', 'coupon/receive');
    Route::get('/getList', 'coupon/getList');
})->allowCrossDomain($domain)->middleware('verify');

//案例
Route::group('documentation', function () {
    Route::get('/index', 'documentation/index');
    Route::get('/info', 'documentation/info');
    Route::get('/getList', 'documentation/getList');
})->allowCrossDomain($domain);

//师傅
Route::group('worker', function () {
    Route::get('/getList', 'worker/getList');
})->allowCrossDomain($domain);

//授权登录
Route::group('login', function () {
    Route::get('/index', 'login/index');
    Route::post('/sign_in', 'login/sign_in');
    Route::post('/Login', 'login/Login');
    Route::rule('/forget', 'login/forget','get|post');
    Route::post('/check', 'login/check');
    Route::post('/miniAppletLogin', 'login/miniAppletLogin');
    Route::get('/wechat_open', 'login/wechat_open');
    Route::get('/getOpenid', 'login/getOpenid');
})->allowCrossDomain($domain);

//支付回调
Route::group('callback', function () {
    Route::rule('/wechatCallback', 'callback/wechatCallback');
    Route::rule('/aliPayOrder', 'callback/aliPayOrder');
    Route::rule('/product_save', 'callback/product_save');
    Route::rule('/RemitCallback', 'callback/RemitCallback');
    Route::rule('/autoOssBackup', 'callback/autoOssBackup');
    Route::rule('/statistics', 'callback/statistics');
    Route::rule('/checkSignature', 'callback/checkSignature');
});

//注册
Route::group('register', function () {
    Route::get('/index', 'register/index');
    Route::post('/save', 'register/save');
})->allowCrossDomain($domain);

//商品
Route::group('product', function () {
    Route::get('/index', 'product/index');
    Route::get('/cate', 'product/cate');
    Route::get('/ProductList', 'product/ProductList');
    Route::get('/details', 'product/details');
    Route::get('/comment_list', 'product/comment_list')->middleware('verify');
    Route::post('/submit', 'product/submit')->middleware('verify');
    Route::post('/save', 'product/save')->middleware('verify');
    Route::get('/getHistory', 'product/getHistory')->middleware('verify');
    Route::get('/emptySearch', 'product/emptySearch')->middleware('verify');
    Route::get('/company_phone', 'product/company_phone')->middleware('verify');
})->allowCrossDomain($domain);

//购物车
Route::group('cart', function () {
    Route::get('/index', 'cart/index');
    Route::post('/add', 'cart/add');
    Route::post('/edit', 'cart/edit');
    Route::post('/submit', 'cart/submit');
})->allowCrossDomain($domain)->middleware('verify');

//订单相关
Route::group('order', function () {
    Route::get('/index', 'order/index');
    Route::get('/getTemporary', 'order/getTemporary');
    Route::post('/payment', 'order/payment');
    Route::get('/my_order', 'order/my_order');
    Route::get('/my_order_details', 'order/my_order_details');
    Route::post('/drawback', 'order/drawback');
    Route::get('/getList', 'order/getList');
    Route::get('/getOrderProduct', 'order/getOrderProduct');
    Route::post('/addEvaluatet', 'order/addEvaluatet');
    Route::post('/submit', 'order/submit');
    Route::post('/deduction_amount', 'order/deduction_amount');
    Route::post('/confirmPayment', 'order/confirmPayment');
    Route::post('/edit', 'order/edit');
    Route::post('/drawback_save', 'order/drawback_save');
})->allowCrossDomain($domain)->middleware('verify');

//个人中心
Route::group('user', function () {
    Route::get('/get_user', 'user/get_user');
    Route::get('/mechanism_details', 'user/mechanism_details');
    Route::post('/edit', 'user/edit');
    Route::post('/get_mobile', 'user/get_mobile');
    Route::get('/collection', 'user/collection');
    Route::get('/warranty', 'user/warranty');
    Route::get('/getUserQrcode', 'user/getUserQrcode');
    Route::get('/wechat', 'user/wechat');
    Route::get('/my_team', 'user/my_team');
    Route::get('/method_index', 'user/method_index');
    Route::get('/method_info', 'user/method_info');
    Route::post('/method_save', 'user/method_save');

})->allowCrossDomain($domain)->middleware('verify');

//资产 - 我的账户
Route::group('account', function () {
    Route::get('/index', 'account/index');
    Route::get('/record/:type', 'account/record');
    Route::get('/getList', 'account/getList');
})->allowCrossDomain($domain)->middleware('verify');

//充值相关
Route::group('remit', function () {
    Route::get('/remit_account', 'remit/remit_account');
    Route::get('/record', 'remit/record');
    Route::get('/getList', 'remit/getList');
    Route::post('/save', 'remit/save');
})->middleware('verify');

//提现相关
Route::group('draw', function () {
    Route::get('/index', 'draw/index');
    Route::get('/record', 'draw/record');
    Route::get('/getList', 'draw/getList');
    Route::post('/save', 'draw/save');
    Route::get('/bank_list', 'draw/bank_list');
})->allowCrossDomain($domain)->middleware('verify');

//互转相关
Route::group('transfer', function () {
    Route::get('/index', 'transfer/index');
    Route::get('/record', 'transfer/record');
    Route::get('/getList', 'transfer/getList');
    Route::get('/verify', 'transfer/verify');
    Route::post('/save', 'transfer/save');
})->allowCrossDomain($domain)->middleware('verify');

//转换相关
Route::group('exchange', function () {
    Route::get('/index', 'exchange/index');
    Route::get('/record', 'exchange/record');
    Route::get('/getList', 'exchange/getList');
    Route::post('/save', 'exchange/save');
})->middleware('verify');

//答疑相关
Route::group('answer', function () {
    Route::get('/getList', 'answer/getList');
    Route::post('/addAnswer', 'answer/addAnswer');
})->middleware('verify');

//意见反馈
Route::group('message', function () {
    Route::get('/index', 'message/index');
    Route::post('/save', 'message/save');
})->allowCrossDomain($domain)->middleware('verify');

Route::group('mechanism', function () {
    Route::get('/getList', 'mechanism/getList');
    Route::get('/index', 'mechanism/index');
    Route::post('/save', 'mechanism/save');
    Route::get('/receive_list', 'mechanism/receive_list');
    Route::get('/upload_list', 'mechanism/upload_list');
})->allowCrossDomain($domain)->middleware('verify');

Route::group('enterprise', function () {
    Route::get('/index', 'enterprise/index');
    Route::post('/save', 'enterprise/save');
})->allowCrossDomain($domain)->middleware('verify');

//安全中心
Route::group('security', function () {
    Route::get('/index', 'security/index');
    Route::post('/save', 'security/save');
})->middleware('verify');

//地址相关
Route::group('address', function () {
    Route::get('/index', 'address/index');
    Route::get('/add', 'address/add');
    Route::get('/edit', 'address/edit');
    Route::get('/getArea', 'address/getArea');
    Route::post('/save', 'address/save');
    Route::post('/chooseDefault', 'address/chooseDefault');
    Route::post('/delete', 'address/delete');
    Route::post('/choice', 'address/choice');
})->allowCrossDomain($domain)->middleware('verify');

//上传
Route::group('uploads', function () {
    Route::rule('/uploadImage', 'uploads/uploadImage');
})->allowCrossDomain($domain);
